From a7c457e8033c2b0d0b107ed2f14d39315393aff2 Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Fri, 15 Jul 2016 10:31:06 -0400 Subject: [PATCH] Add tests --- tests/freshness.rs | 65 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/tests/freshness.rs b/tests/freshness.rs index f5173bebc..ae6275486 100644 --- a/tests/freshness.rs +++ b/tests/freshness.rs @@ -360,3 +360,68 @@ fn same_build_dir_cached_packages() { [COMPILING] a2 v0.0.1 ({dir}/a2) ", dir = p.url()))); } + +#[test] +fn no_rebuild_if_build_artifacts_move_backwards_in_time() { + let p = project("backwards_in_time") + .file("Cargo.toml", r#" + [package] + name = "backwards_in_time" + version = "0.0.1" + authors = [] + + [dependencies] + a = { path = "a" } + "#) + .file("src/lib.rs", "") + .file("a/Cargo.toml", r#" + [package] + name = "a" + version = "0.0.1" + authors = [] + "#) + .file("a/src/lib.rs", ""); + + assert_that(p.cargo_process("build"), + execs().with_status(0)); + + p.root().move_into_the_past(); + p.root().join("target").move_into_the_past(); + + assert_that(p.cargo("build").env("RUST_LOG", ""), + execs().with_status(0).with_stdout("").with_stderr("")); +} + +#[test] +fn rebuild_if_build_artifacts_move_forward_in_time() { + let p = project("forwards_in_time") + .file("Cargo.toml", r#" + [package] + name = "forwards_in_time" + version = "0.0.1" + authors = [] + + [dependencies] + a = { path = "a" } + "#) + .file("src/lib.rs", "") + .file("a/Cargo.toml", r#" + [package] + name = "a" + version = "0.0.1" + authors = [] + "#) + .file("a/src/lib.rs", ""); + + assert_that(p.cargo_process("build"), + execs().with_status(0)); + + p.root().move_into_the_future(); + p.root().join("target").move_into_the_future(); + + assert_that(p.cargo("build").env("RUST_LOG", ""), + execs().with_status(0).with_stdout("").with_stderr("\ +[COMPILING] a v0.0.1 ([..]) +[COMPILING] forwards_in_time v0.0.1 ([..]) +")); +} -- 2.30.2